import { request } from '@/service/request';

// ---------- Apply ----------

/** get apply list */
export function fetchGetDmApplyPage(params?: Api.Dimo.ApplySearchParams) {
  return request<Api.Dimo.ApplyList>({
    url: '/dm_apply/page',
    method: 'GET',
    params
  });
}

/** get */
export function fetchGetDmApply(id: string) {
  return request<Api.Dimo.Apply>({
    url: `/dm_apply/${id}`,
    method: 'GET'
  });
}

/** add apply info */
export function fetchAddDmApply(data: Api.Dimo.ApplyEdit) {
  return request<boolean>({
    url: '/dm_apply/',
    method: 'POST',
    data
  });
}

/** update apply info */
export function fetchUpdateDmApply(data: Api.Dimo.ApplyEdit) {
  return request<boolean>({
    url: '/dm_apply/',
    method: 'PUT',
    data
  });
}

/** edit delete apply */
export function fetchDeleteDmApply(data: Api.Common.DeleteParams) {
  return request<boolean>({
    url: '/dm_apply/',
    method: 'DELETE',
    data
  });
}

/** auth */
export function fetchAuthDmApply(data: { id: string; status: string; authRejectReason: string }) {
  return request<boolean>({
    url: `/dm_apply/auth`,
    method: 'PUT',
    data
  });
}

// 导出

export function fetchAuthDmApplyExport(data: Api.Dimo.DmExportParams) {
  return request<boolean, 'blob' | 'json'>({
    url: `/dm_apply/export_data`,
    method: 'POST',
    data,
    responseType: 'blob'
  });
}
